
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>游戏盒子 - 小说编辑</title>
    


    <link rel="shortcut icon" href="favicon.ico">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    
    
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>游戏盒子
                        <small>小说编辑</small>
                    </h5>
                    
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal">
                    	<input type="hidden" id="id" name="id" value="{$data['game_info']['id']}">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用名称</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="title" value="{$data['game_info']['title']}" id="title">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="sort" value="{$data['game_info']['sort']}" id="sort">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用的appid</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="appid" id="appid" value="{$data['game_info']['appid']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用url</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="url" id="url" value="{$data['game_info']['url']}">
                                
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用版本</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="envversion" id="envversion"  value="{$data['game_info']['envversion']}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">用用logo</label>

                            <!--<div class="col-sm-10">-->
                                <!--<input type="text" class="form-control" name="logo" value="{$data['game_info']['logo']}" id="logo">-->
                            <!--</div>-->
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="logo" value="{$data['game_info']['logo']}" id="logo">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="content" value="{$data['game_info']['content']}" id="content">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否显示</label>

                            <div class="col-sm-10">

                                <!---  中间是否显示：1显示，0不显示  -->
                                <select class="form-control m-b" name="isshow" id="isshow">
                                    <option value="0" <?php if( $data['game_info']['isshow'] == 0){ echo 'selected="selected"';}  ?>>不显示</option>
                                    <option value="1" <?php if( $data['game_info']['isshow'] == 1){ echo 'selected="selected"';}  ?>>显示</option>

                                </select>
                            </div>
                                
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用类型</label>

                            <div class="col-sm-10">

                                <!-- 1小程序，2H5，3客服 -->
                                <select class="form-control m-b" name="category" id="category">
                                    <option value="1" <?php if( $data['game_info']['category'] == 1){ echo 'selected="selected"';}  ?>>小程序</option>
                                    <option value="2" <?php if( $data['game_info']['category'] == 2){ echo 'selected="selected"';}  ?>>H5应用</option>
                                    <option value="3" <?php if( $data['game_info']['category'] == 3){ echo 'selected="selected"';}  ?>>客服</option>
                                </select>
                            </div>
                                
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">显示H5</label>

                            <div class="col-sm-10">

                                <select class="form-control m-b" name="h5show" id="h5show">
                                    <option value="false" <?php if( $data['game_info']['h5show'] == false){ echo 'selected="selected"';}  ?>>否</option>
                                    <option value="frue" <?php if( $data['game_info']['h5show'] == true){ echo 'selected="selected"';}  ?>>是</option>
                                </select>
                            </div>
                        </div>
                        
                        <div class="hr-line-dashed"></div>
                       
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onClick="save()">保存内容</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Public/Admin/js/contabs.min.js?v=1.0"></script>
<script src="/Public/Admin/js/plugins/layer/layer.js?v=1.0"></script>
<script>
    
	var lock = 0;
	function save()
	{
		if(lock == 1){ return false;}
        var id = $('#id').val();
        var title = $('#title').val();
        var sort = $('#sort').val();
        var appid = $('#appid').val();
        var url = $('#url').val();
        var envversion = $('#envversion').val();
        var content = $('#content').val();
        var isshow = $('#isshow').val();
        var category = $('#category').val();
        var h5show = $('#h5show').val();

        var logo = $('#logo')[0].files[0];

        var formdata = new FormData();

        formdata.append('id',id);
        formdata.append('title',title);
        formdata.append('sort',sort);
        formdata.append('appid',appid);
        formdata.append('url',url);
        formdata.append('envversion',envversion);
        formdata.append('content',content);
        formdata.append('isshow',isshow);
        formdata.append('category',category);
        formdata.append('h5show',h5show);

        formdata.append('logo',logo);
		
		var url = "{:U('GameBox/game_fiction_edit')}";
		$.ajax({
				type : 'post',
				url  : url+'?t='+Math.random(),
                data : formdata,
                dataType : 'json',
                cache: false,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
				beforeSend: function(){
					lock = 1;
					layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
				},
				success : function(res){
					layer.closeAll();
					if(res.state > 0){
					  layer.msg('更新成功', {icon: 1});
					  var t = window.setTimeout("reload()",2000); 
								
					}else{
						layer.msg(res.error, {icon: 2});
					}
				},
				complete: function(){
					lock = 0;
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.closeAll();
					layer.msg('网络失败，请刷新页面后重试', {icon: 2});		
				}
		})		
	}
	
	
	function reload()
	{
		//document.location.reload();//当前页面 
		location.href = "{:U('GameBox/game_fiction')}?";
	}
	
</script>

</body>

</html>
